<%@ page contentType="text/html; charset=UTF-8" buffer="16kb"%>
<%@ include file="../include/taglib.jsp"%>
<%
    response.setHeader("Cache-Control", "no-store");
    response.setHeader("Pragrma", "no-cache");
    response.setDateHeader("Expires", 0);
    Long resid = Long.parseLong(request.getParameter("id"));
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>linux综合性能页面</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="expires" content="0" />
<meta name="Keywords" content=" " />
<meta name="Description" content=" " />
<%@ include file="../include/common.jsp"%>


<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath}/style/default/bsm/sub_menu.css" />
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath}/style/default/bsm/perf/listPage.css" />
<script type="text/javascript"
	src="${pageContext.request.contextPath}/resources/charts/FusionCharts.js"></script>
	
<script type="text/javascript"
	src="${pageContext.request.contextPath}/resources/charts/FusionCharts.jqueryplugin.js"></script>
	
<script type="text/javascript"
	src="${pageContext.request.contextPath}/js/common/Xslider.js"></script>
	
<script type="text/javascript">
	
    var  cpuChart;
	function initNet(){
		if(typeof cpuChart == undefined || cpuChart == null){
			 cpuChart =  new FusionCharts( "${pageContext.request.contextPath}/resources/charts/MSSpline.swf?ChartNoDataText=没有数据","cpuChart1", "100%", "100%", "0", "1" );
		 }

		$.ajax({
			url : 'real-time!childResListForGrand.action', // 
			type : 'POST',
			dataType : "json",
			data : {
				resId :<%=resid %>,
				childType:'1203020100000',
				grandchildType:'1203020600000'
			},
			success : function(data) { //
				$('#videolistwraper > .videolist ul ').remove('li');
				$.each(data.res,function(i,index){
					$('#videolistwraper > .videolist ul ').append('	<li><span id='+index.id+' class="listspan">'+index.name+'</span> </li>');
				});		
				//最多显示三个   一次移动两个   不可循环   垂直滚动
				$("#videolistwraper").Xslider({
					unitdisplayed : 4,
					numtoMove : 2,
					loop : "cycle",
					dir : "V"
				});
				//给每一列加点击操作
				$('#videolistwraper .videolist ul li').click(function(){
					$(this).addClass('liselected').siblings().removeClass('liselected');
					$.ajax({
						url : 'real-time!get2LineChart.action', // 
						type : 'POST',
						dataType : "json",
						data : {
							resId :$(this).children('span').attr('id'),
							propIds:'120302060000002'
						},
						success : function(dataset) {
							cpuChart.setJSONData(dataset);
							cpuChart.render("cpuChartDiv");
						}
					});
				});
				//触发第一个
				$('#videolistwraper .videolist ul li :first').click();
			}
		});
	}
	

	var threadChart;
	var sessionChart;
	function initTreadPool(){
		//线程池
		if(typeof threadChart == undefined || threadChart == null){
			threadChart =  new FusionCharts( "${pageContext.request.contextPath}/resources/charts/Column2D.swf","threadChart111", "100%", "130", "0", "1" );
		}
		$.ajax({
			url : 'real-time!get2ColumnChartForGrand.action', // 
			type : 'POST',
			dataType : "json",
			data : {
				resId :<%=resid %>,
				detail:1,
				childType:'1203020100000',
				grandchildType:'1203020300000',
				propIds:'120302030000001',
				top:'10'
			},
			success : function(data) {
				threadChart.setJSONData(data);
				threadChart.render("threadPoolCol");
			}
		});
		
		//会话
		if(typeof sessionChart == undefined || sessionChart == null){
			sessionChart =  new FusionCharts( "${pageContext.request.contextPath}/resources/charts/Column2D.swf","sessionChart11", "100%", "130", "0", "1" );
		}
		$.ajax({
			url : 'real-time!get2ColumnChartForGrand.action', // 
			type : 'POST',
			dataType : "json",
			data : {
				resId :<%=resid %>,
				detail:1,
				childType:'1203020100000',
				grandchildType:'1203020500000',
				propIds:'120302050000001',
				top:'10'
			},
			success : function(data) {
				sessionChart.setJSONData(data);
				sessionChart.render("sessionCol");
			}
		});
	}
    
	
	var heapChart;
	var fsColChartc;
	var memChart;
	var transChart;
	function initBaseInfo(){
			
			//基本信息
			$.ajax({
				url : 'real-time!getBaseInfo.action', // 
				type : 'POST',
				dataType : "json",
				data : {
					resId :<%=resid %>,
					propIds:'attr_110302000000001'
				},
				success : function(data) {
					$('#attr_110302000000001').text(data.attr_110302000000001); 
					$('#resIp').text(data.ip);
				}
			});
			
			
			//JVMcpu
			$.ajax({
				url : 'real-time!getHLineGauge.action', // 
				type : 'POST',
				dataType : "json",
				data : {
					resId :<%=resid %>,
					childType:'1203020100000', 
					grandchildType:'1203020200000', 
					maxPropId:'100',
					usePropId:'120302020000005',
					unit:'%'
				},
				success : function(data) {
					if(typeof heapChart == undefined || heapChart == null){
						heapChart =  new FusionCharts( "${pageContext.request.contextPath}/resources/charts/HLinearGauge.swf?ChartNoDataText=没有数据","heapChart1", "100%", "130", "0", "1" );
					}
					heapChart.setJSONData(data);
					heapChart.render("jvmcpuChart");
				}
			});
			
			//JVM内存
			$.ajax({
				url : 'real-time!getHLineGauge.action', // 
				type : 'POST',
				dataType : "json",
				data : {
					resId :<%=resid %>,
					childType:'1203020100000',
					grandchildType:'1203020200000',
					maxPropId:'120302020000002',
					usePropId:'120302020000003',
					unit:'MB'
				},
				success : function(data) {
					if(typeof memChart == undefined || memChart == null){
						memChart =  new FusionCharts( "${pageContext.request.contextPath}/resources/charts/HLinearGauge.swf?ChartNoDataText=没有数据","memChart11", "100%", "130", "0", "1" );
					}
					memChart.setJSONData(data);
					memChart.render("jvmmemChart");
				}
			});
			
			//事务 
			$.ajax({
				url : 'real-time!getHLineGauge.action', // 
				type : 'POST',
				dataType : "json",
				data : {
					resId :<%=resid %>,
					childType:'1203020100000',
					grandchildType:'1203020400000',
					maxPropId:'100',
					usePropId:'120302040000003',
					unit:'%'
				},
				success : function(data) {
					if(typeof transChart == undefined || transChart == null){
						transChart =  new FusionCharts( "${pageContext.request.contextPath}/resources/charts/HLinearGauge.swf?ChartNoDataText=没有数据","transChart11", "100%", "130", "0", "1" );
					}
					transChart.setJSONData(data);
					transChart.render("tranRBChart");
				}
			});
			
			
			//连接池使用率
			if(typeof fsColChartc == undefined || fsColChartc == null){
				fsColChartc =  new FusionCharts( "${pageContext.request.contextPath}/resources/charts/Column2D.swf","fsColChart11", "100%", "130", "0", "1" );
			}
			$.ajax({
				url : 'real-time!get2ColumnChartForGrand.action', // 
				type : 'POST',
				dataType : "json",
				data : {
					resId :<%=resid %>,
					detail:1,
					childType:'1203020100000',
					grandchildType:'1203020700000',
					propIds:'120302070000006',
					top:'5'
				},
				success : function(data) {
					fsColChartc.setJSONData(data);
					fsColChartc.render("fsColChart");
				}
			});
	}
	
	
	
	$(function() {
			initBaseInfo();
			initTreadPool();
			initNet();
		//CPU 内存 每10S刷新一次
		setInterval('initBaseInfo()',60000);
		
	});
</script>

</head>
<body>
	
	<div class="column">
		<div class="col-main">
			<!--基本信息-->
			<div class="col-l-extra h-400">
			<h2 class="title-h2 m-0">基本信息</h2>
			<ul class="col-l-ul">
					<li><span class="col-l-ul-l" >中间件类别:</span><span 
								class="col-l-ul-r"><img src="${pageContext.request.contextPath}/style/default/bsm/perf/images/websphere24_24.png"></span>
					</li>
					<li><span class="col-l-ul-l" class="baseinfo">IP:</span><span id="resIp"
						class="col-l-ul-r"></span>
					</li>
					<li><span class="col-l-ul-l" class="baseinfo">服务器端口:</span><span id="attr_110302000000001"
						class="col-l-ul-r"></span>
					</li>
			</ul>
			</div>
			<!--@end基本信息-->
			<div class="col-r-main">
				<div class="col-v-rate-extra" >
				<h2 class="title-h2 m-0">JVM占用CPU率</h2>
					<div id="jvmcpuChart"></div>
				</div>
				<!--@end基本信息-->
				<div class="col-v-rate-extra f-r">
				<h2 class="title-h2 m-0">JVM内存</h2>
				   <div id="jvmmemChart"></div>
			    </div>
			    
			     <div class="col-v-rate-extra">
		            <h2 class="title-h2 m-0">连接池使用率 TOP5</h2>
			       <div id="fsColChart"></div>
			    </div>
			    
				<div class="col-v-rate-extra f-r">
				<h2 class="title-h2 m-0">事务回滚率</h2>
				   <div id="tranRBChart"></div>
			    </div>
		 </div>   
	  </div>
	</div>

		<div class="column b-1">
			  <h2 class="title-h2 m-0">线程池线程数 TOP10</h2>
			  <div class="col-r-main h-150" style="width:100%;">
		           <div id="threadPoolCol"></div>
			  </div>
		</div>
		
		<div class="column b-1">
			  <h2 class="title-h2 m-0">会话管理器会话数 TOP10</h2>
			  <div class="col-r-main h-150" style="width:100%;">
		           <div id="sessionCol"></div>
			  </div>
		</div>
		
		<div class="column b-1">
						<h2 class="title-h2 m-0">网络应用程序子资源 [当天趋势图]-[请求数]</h2>
							<div class="col-l-extra"  style="width:20%">
							<ul class="col-l-ul">
								<div id="videolistwraper">
								 <a class="abtn aright" href="#down"></a>
									<div class="videolist">
										<ul>
										</ul>
									</div>
									<a class="abtn aleft" href="#up" ></a>
								</div>
							</ul>
						</div>
					    <div class="col-net-main p-75">
						    <div id="cpuChartDiv"></div>
					    </div>
	     </div>
		 <div class="column" style="width:100%;height:5px;"></div>
</body>